#!/bin/bash

. $TEST_ROOT_DIR/run-test-common

python -c "import sys; print('Python: %s'%sys.version)" || exit 1
python -c "import numpy; print('NumPy: %s'%numpy.version.full_version)" || exit 1
python -c "import scipy; print('SciPy: %s'%scipy.version.full_version)" || exit 1
python -c "import pytest; print('PyTest: %s'%pytest.__version__)" || exit 1

# We run each example in a separate process. Thus, if you run the full pytest session on your machine,
# you may see varying behavior, e.g., due effects on CNTK globals, causing later tests to fail.

ERRORS=0
# Note: keep pattern below in sync with pytest.ini
for t in *_test.py; do
  py.test --verbose --deviceid $TEST_DEVICE "$t"
  # Allow exit 0 (all run successfully) and 5 (no test to run)
  (( $? == 0 || $? == 5 )) || ((ERRORS++))
done

if (( ERRORS == 0 )); then
  echo "__COMPLETED__"
fi
